/*
 * Copyright 2015 William Wang.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package wxk.Bonus.utils;

import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

/**
 * Jan 21, 20158:30:32 AM
 * @author William Wang
 */
public class ScreenUtil {
 static private double avaliable_screen_height=-1;
 static private double avaliable_screen_width=-1;
 static private int avaliable_TaskBar_Height=-1;
 static private ScreenUtil global=null;
 //get active windows
 static private double titlebar_height=0;

    public  double getTitlebar_height() {
        return titlebar_height;
    }

    public  void setTitlebar_height(double titlebar_height) 
    {
      BonusLogger.getInstance().log("Activie windows title bar height:"+titlebar_height);
        ScreenUtil.titlebar_height = titlebar_height;
    }
 private ScreenUtil(){
 initScreenConfig();    
 } ;
 static public ScreenUtil getInstance()
 {
  if(global==null)global = new ScreenUtil();   
  return global;
 }
  public  int getTaskBarHeight()
  {
    return   avaliable_TaskBar_Height;
  }
  public void initScreenConfig()
  {
//get Window bottom TaskBar Height      
Dimension sc=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
 BonusLogger.getInstance().log(String.format("1....%d,%d\n,",sc.width,sc.height));                 
Rectangle rec=GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); 
avaliable_screen_height = rec.getHeight();
avaliable_screen_width = rec.getWidth();
avaliable_TaskBar_Height=sc.height-rec.height;    

BonusLogger.getInstance().log(String.format("2.....%d,%d,,,%d\n,",rec.width,rec.height,avaliable_TaskBar_Height));  

}

    public  double getAvaliable_screen_height() {
        return avaliable_screen_height;
    }

    public  double getAvaliable_screen_width() {
        return avaliable_screen_width;
    }
  
}